﻿using SolidWorks.Interop.sldworks;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace SolidWorksStudy
{
    public class Utility
    {
        public static SldWorks SwApp { get; private set; }
        public static SldWorks ConnectToSolidWorks()
        {
            if (SwApp != null)
            {
                return SwApp;
            }
            else
            {
                try
                {
                    SwApp = (SldWorks)Marshal.GetActiveObject("SldWorks.Application");
                    Debug.Print("Connect to solidworks on " + DateTime.Now);

                }
                catch
                {
                    MessageBox.Show("Could not connect to SoildWorks!");
                    SwApp = null;
                }
            }
            return SwApp;

        }
        /// <summary>
        /// 创建配合
        /// </summary>
        /// <param name="type">配合类型：1 平行、2 垂直</param>
        public static void CreateMate(int type)
        {
            
        }
    }
}
